﻿using System;

namespace DotNetCommon.Validate.Annotations;

/// <summary>
/// 表示字符串不能是其中之一, 示例:
/// <code>
/// [VNotInString(["A", "B", "C", "D"], true)]
/// public string Score { get; set; }
/// </code>
/// </summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)]
public class VNotInStringAttribute(string[] values, bool ignoreCase = false, string errorMessage = null) : Attribute, IValidateAction
{
    public string[] Values { get; internal set; } = values;
    public bool IgnoreCase { get; internal set; } = ignoreCase;
    public string ErrorMessage { get; internal set; } = errorMessage;

    public void Action(IValidateContext ctx)
    {
        ValidateStringExtensions.MustNotInStringInternal(ctx, Values, IgnoreCase, ErrorMessage);
    }
}
